package com.mbc.rmt.manager;

import com.mbc.common.manager.AbstractMgr;
import com.mbc.common.utils.KeyGenerator;
import com.mbc.rmt.dao.BranchBalanceDAO;
import com.mbc.rmt.dao.RemittanceDAOFactory;
import com.mbc.rmt.entities.BranchBalance;

public class BranchBalanceMgr extends AbstractMgr {
	
private BranchBalanceDAO branchbalanceDAO;
	
	public BranchBalanceMgr (){}
	
	public BranchBalanceMgr(String sessionId) {
		this.sessionId = sessionId;
	}

	public void create(BranchBalance entity) throws Exception {
		openConnection();
		try {
			branchbalanceDAO = RemittanceDAOFactory.getBranchBalanceDAO(dbManager
					.getConnection());
			entity.setBranchbalance_id(KeyGenerator.generateKey(getConnection()));
			branchbalanceDAO.create(entity);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}

	public void update(BranchBalance entity) throws Exception {
		openConnection();
		try {
			branchbalanceDAO = RemittanceDAOFactory.getBranchBalanceDAO(dbManager
					.getConnection());
			branchbalanceDAO.update(entity);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}

	public void delete(long key) throws Exception {
		openConnection();
		try {
			branchbalanceDAO = RemittanceDAOFactory.getBranchBalanceDAO(dbManager
					.getConnection());
			branchbalanceDAO.delete(key);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}

}
